<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2015-08-08 10:14:54
  - Description:
-->
<head>
<title>添加常用评价</title>
   <%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<%
		String typeFlg = "";
		if(request.getParameter("typeFlg")!=null){
			typeFlg = (String)request.getParameter("typeFlg");
		}
	%>
</head>
<body>
	<div id="form1" style="width:100%;overflow:hidden;">
		<input class="nui-hidden" name="oftenOpinion.oftenopinionid" />
		<table style="width:100%;table-layout:fixed;" class="nui-form-table" >
			  <tr>
		        <th class="nui-form-label">流程：</th>
		        <td colspan="3"><input id="processid" name="oftenOpinion.processid" class="nui-lookup" style="width:200px;" 
        							textField="processchname" valueField="processid" popupWidth="auto" popup="#gridPanel" grid="#processDataGrid" multiSelect="false"/></td>
		      </tr>
		      <tr class="odd">
		        <th class="nui-form-label"><font color="red">*</font>&nbsp;常用评价：</th>
		        <td colspan="3"><input id="remark" class="nui-textarea nui-form-input" name="oftenOpinion.remark"  vtype="maxLength:4000" /></td>
		      </tr>
		</table>
	</div>
	<div id="toolBar" class="nui-toolbar" style="text-align:center;padding-top:5px;padding-bottom:5px;" 
	    borderStyle="border:0;">   
	    <span style="display:inline-block;width:25px;"></span>    
	    <a class="nui-button"  style="width:60px;" iconCls="icon-save" onclick="save">保存</a>
	    <span style="display:inline-block;width:25px;"></span>
	    <a class="nui-button" id="cancelBtn" iconCls="icon-cancel" style="width:60px;" onclick="cancel">取消</a>
	    <span style="display:inline-block;width:25px;"></span>
		<a class="nui-button" iconCls="icon-help" onclick="openHelpPopup('oftenOpinion_add','新增常用评价')">说明</a>
	</div>
	
	<!-- 流程选择  -->
	<div id="gridPanel" class="nui-panel" title="header" iconCls="icon-add" style="width:380px;height:180px;" 
        showToolbar="true" showCloseButton="true" showHeader="false" bodyStyle="padding:0" borderStyle="border:0" 
    >
        <div property="toolbar" style="padding:5px;padding-left:8px;text-align:center;">   
            <div style="float:left;padding-bottom:2px;">
                <span>流程名称：</span>                
                <input id="keyText" class="nui-textbox" style="width:160px;" onenter="onSearchClick"/>
                <a class="nui-button" onclick="onSearchClick">查询</a>
                <a class="nui-button" onclick="onClearClick">清除</a>
            </div>
            <div style="float:right;padding-bottom:2px;">
                <a class="nui-button" onclick="onCloseClick">关闭</a>
            </div>
            <div style="clear:both;"></div>
        </div>
        <div id="processDataGrid" class="nui-datagrid" style="width:100%;height:100%;" 
            borderStyle="border:0" showPageSize="false" showPageIndex="false"
            dataField = "datas" url="com.atozsoft.wf.common.queryWorkflowList.biz.ext" 
        >
            <div property="columns">
                <div type="checkcolumn" ></div>
                <div field="processid" width="30" headerAlign="center" allowSort="true">编号</div>    
                <div field="processchname" width="50" headerAlign="center" allowSort="true">名称</div>
                <div field="description" width="120" headerAlign="center" allowSort="true">描述</div>
            </div>
        </div>  
    </div>
</body>
</html>
<script>
	nui.parse();
	var form = new nui.Form("#form1");
	
	//流程选择panel
    var gridprocess = mini.get("processDataGrid");
    var keyText = nui.get("keyText");

	gridprocess.load();

    function onSearchClick(e) {
        gridprocess.load({
            key: keyText.value
        });
    }
    function onCloseClick(e) {
        var lookup2 = nui.get("processid");
        lookup2.hidePopup();
    }
    function onClearClick(e) {
        var lookup2 = nui.get("processid");
        lookup2.deselectAll();
    }

	// 保存
	function save() {
	    // 校验
	    form.validate();
	    if (form.isValid() == false) return;
        
	    var o = form.getData();
	    var json = nui.encode(o);
	    $.ajax({
	        url: "com.atozsoft.wf.common.addProcessOftenOpinion.biz.ext",
	        type: 'POST',
	        data: json,
	        cache: false,
	        contentType: 'text/json',
	        success: function (text) {
	            var response = text.result || "";
	            if (response == "SUCCESS") {
	               nui.alert("数据保存成功！", "提示", function(){
	                   CloseWindow("ok");
	               });
	            } else {
	                nui.alert("数据保存失败，请联系管理员！","提示");
	            }
	        },
	        error: function (jqXHR, textStatus, errorThrown) {
	            nui.alert(jqXHR.responseText, "提示");
	            CloseWindow();
	        }
	    });
	}

	// 取消
	function cancel() {
	    CloseWindow("cancel");
	}

	// 关闭窗体
    function CloseWindow(action){
      if(action=="close" && form.isChanged()){
        if(confirm("数据已改变,是否先保存?")){
          return false;
        }
      }else if(window.CloseOwnerWindow) 
        return window.CloseOwnerWindow(action);
      else
        return window.close();
    }
</script>